<?php

$tables = $this->cms->session->prepTables();
print '
<div class="module">
	<h3 onclick="CMS.toggleSection(this);">Database Tables</h3>
	<div class="content">
	<table class="data_grid">
		<thead>
			<tr>
			<th>Table</th>
			<th># of Records</th>
			<th>Last Updated</th>
			</tr>
		</thead>
		<tbody class="records">';
$rc = 0;
foreach($tables as $key => $row){
	($rc%2==0) ? $class='' : $class='class="odd"';
	print "<tr $class>";
	
	$click = 'onclick="window.location = \'' . BLACKBIRD_ROOT . 'browse/' . $key . '\';"';
	
	print "<td $click>" . $key . '</td>';
	
	$q_m = $this->db->query("SELECT id FROM $key");
	
	print "<td $click>" . count($q_m) . '</td>';
	
	$q_last = $this->db->queryRow("SELECT * FROM ".BLACKBIRD_TABLE_PREFIX."history WHERE table_name = '$key' ORDER BY modtime LIMIT 1");
	$deets = $this->db->queryRow("SELECT firstname,lastname,email FROM " . BLACKBIRD_USERS_TABLE . " WHERE id = '$q_last[user_id]'");
							
	print "<td $click>". $deets['lastname'] . ', ' . $deets['firstname'] . ' ' . $q_last['modtime'] . '</td>';
	print '</tr>';
	
	$rc++;
	
}

print '</tbody>
</table>
</div>
</div>';